package com.shiguiwu.springmybatis.spring.lifecycle.instance;

import com.shiguiwu.springmybatis.spring.lifecycle.definition.User;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;

/**
 * @description: 6.0, 实例前阶段
 * @author: stone
 * @date: Created by 2021/3/24 20:43
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.spring.lifecycle.instance
 */
public class InstancedTests {

    public static void main(String[] args) {


        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
        //实例化前的干预
        factory.addBeanPostProcessor(new UserBeanPostProcessor());
        //定义个
        BeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(User.class)
                //改修名称
                .addPropertyValue("name", "周冬")
                .getBeanDefinition();
        //注册定义对象
        factory.registerBeanDefinition("user", definition);
        System.out.println(factory.getBean("user"));


    }


}


